#import the sys module
import sys
#import the date module
from datetime import date
#import project modules
from groupsNusers import user
from groupsNusers import group

#gRL is the group ROOT LIST and contains all groups
gRL = {}
#uRL is the user ROOT LIST and contains all users
uRL = {}
#The current logged on user
currentUser = None

#The main command loop
while True:
    #Take in a command
    cmd = input()
    #If the input fits a command or sub command
    if cmd[:4] == 'user':
        #checks for the sub command create
        if cmd[5:11] == 'create':
            #If there is no username specified than give error
            if cmd[12:] == '':
                print('To create a user type \'user create [username]\'')
            else:
                #create and store new user
                uRL[cmd[12:]] = user(cmd[12:])
                #log the user on
                currentUser = uRL[cmd[12:]]
                #inform user of login success
                print('User login success, logged on to: ' + uRL[cmd[12:]].name)
        elif cmd[5:10] == 'login':
            if cmd[11:] == '':
                print('Please type a name you would like to login into')
            else:
                currentUser = uRL[cmd[12:]]
        elif cmd[5:] == '':
            print('User management commands include: create')
            
    elif cmd[:5] == 'group':
        if cmd[6:12] == 'create':
            gRL[cmd[13:]] = group(currentUser.name)
        elif cmd[6:10] == 'join':
            currentUser.joinGroup()
        elif cmd[6:] == '':
            print('Group management commands include: create')
    elif cmd[:5] == 'event':
        if cmd[6:] == '':
            print('Event management commands include: ???')
    elif cmd == 'help':
        print('Current commands include: user, group, exit')
    elif cmd == 'exit':
        sys.exit()
    else:
        print('Hint: type help')
            
users['user1'] = user()
groups['group2'] = group(input('Groups Creator: '))
users['user2'] = user()
